package com.example.userservice.controller;

import com.example.userservice.feign.OrderFeignClient;
import com.example.userservice.feign.ProductFeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class UserController {
    @Resource
    private OrderFeignClient orderFeignClient;
    @Resource
    private ProductFeignClient productFeignClient;

    @GetMapping("/users/{userId}/orders")
    public String getUserOrders(@PathVariable("userId") Long userId) {
        return "用户 " + userId + " 的订单信息: " + orderFeignClient.getOrdersByUserId(userId);
    }

    @GetMapping("/users/{userId}/products/{productId}")
    public String getUserProductInfo(@PathVariable("userId") Long userId,
                                    @PathVariable("productId") Long productId) {
        return "用户 " + userId + " 查看商品: " + productFeignClient.getProductInfo(productId);
    }
}    